<?php
class SendMessageForm extends Zend_Form {
	
	private $targetUser;
	private $messageType;
	private $bookASIN;
	
	/**
	 * Constructor.
	 * 
	 * @param $messageType
	 * @param $targetUser
	 * @param $bookASIN
	 */
	public function SendMessageForm($messageType, $targetUser, $bookASIN) {
		$this->messageType = $messageType;
		$this->targetUser = $targetUser;
		$this->bookASIN = $bookASIN;
		$this->__construct();
	}
	
	public function init() {
		$this->setMethod("POST");
		$this->setName("SendMSG");
        
		$element = new Zend_Form_Element_Hidden("targetUserId");
		$element->removeDecorator('Label');
		$element->setValue($this->targetUser->id);
		$this->addElement($element);
		
		$element = new Zend_Form_Element_Hidden("messageType");
        $element->setValue($this->messageType);
		$element->removeDecorator('Label');
        $this->addElement($element);
		
        $element = new Zend_Form_Element_Hidden("bookASIN");
        $element->setValue($this->bookASIN);
		$element->removeDecorator('Label');
        $this->addElement($element);
               
		$this->addDisplayGroup(array('targetUserId', "messageType","bookId"),'hiddenBookInfo')->removeDecorator('Label');;
        
        $element = new Zend_Form_Element_Text("to");
        $element->setLabel("To");
        $element->setAttrib("disabled","disabled");
        $element->setDescription("Message will be sent to this user.");
        $element->setValue($this->targetUser->name);
        $this->addElement($element);
        
		$element = new Zend_Form_Element_Text("subject");
		$element->setLabel("Subject");
		$this->addElement($element);
		
		$element = new Zend_Form_Element_Textarea("message");
		$element->setLabel("Message");
		$element->setAttrib('rows',4);
		$this->addElement($element);
		
		$element = new Zend_Form_Element_Submit("send");
		$element->removeDecorator('Label');
		$this->addElement($element);
	}
}
?>